package com.mybatis_puls.demo.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mybatis_puls.demo.entity.Withdraw;
import com.mybatis_puls.demo.service.UserService;
import com.mybatis_puls.demo.service.WithdrawService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 小🌤
 * @since 2020-12-19
 */
@RestController
@RequestMapping("/withdraw")
//withdraw/download.do
public class WithdrawController {
 @Autowired
    private WithdrawService withdrawServicel;
 @Autowired
 private UserService userServicel;

    @GetMapping("/list/{userId}")
   public Object list(@PathVariable("userId") Integer userId){
        QueryWrapper<Withdraw> wrapper=new QueryWrapper<>();
        wrapper.eq("user_id",userId);
        List<Withdraw> list = withdrawServicel.list(wrapper);
        for (Withdraw withdraw : list) {
             withdraw.setUser(userServicel.getById(withdraw.getUserId()));
        }
        return list;
    }
}

